package com.tubeonfire.ajax.admin;

import java.io.IOException;
import java.util.Calendar;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tubeonfire.entity.Playlist;
import com.tubeonfire.model.admin.PlaylistModel;

@SuppressWarnings("serial")
public class ProcessPlaylist extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		String action = request.getParameter("action");
		if (action != null && action.equals("delete")) {
			String id = request.getParameter("id");
			Playlist pl = PlaylistModel.byId(id, false);
			if (pl != null) {
				PlaylistModel.delete(pl);				
			}
		} else if (action != null && action.equals("bump")) {
			String id = request.getParameter("id");
			Playlist pl = PlaylistModel.byId(id, false);
			if (pl != null) {
				pl.setIndexDate(Calendar.getInstance().getTime());
				PlaylistModel.insert(pl);
			}
		}
	}
}
